import _thread
import time


def print_time(threadName, delay):
    count = 0
    while (count < 5):
        time.sleep(delay)
        count += 1
        print("%s:%s" % (threadName, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())))


def testThread():
    try:
        _thread.start_new_thread(print_time, ('thread-1', 2))
        _thread.start_new_thread(print_time, ('thread-2', 4))
    except (Exception) as e:
        print("Error:无法启动线程,", e.args[0])
    finally:
        while 1:
            pass


testThread()
